home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / cp.bat < prev    next >
DOS Batch File  |  1994-06-30  |  1KB  |  44 lines

  1. @echo off
  2. !  cp.bat    Batch file to copy a folder or a file to a folder
  3. !
  4. !  cp name [dest]
  5. !
  6. !  where 'name' is the item to be copied and 'dest' is the folder which
  7. !  shall contain a copy of 'name'. Both names can be preceded by paths and
  8. !  volume IDs.
  9. !  If 'dest' is missing, the current directory is used as destination.
  10. !
  11. !  cp.bat calls copydir
  12. !
  13. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  14. !
  15.  
  16.     ! ensure that the first parameter is there and that the third one is not
  17.     set doserr=13
  18.     if not "%3 " == " " goto ERR_LBL
  19.     if "%1 " == " " goto ERR_LBL
  20.  
  21.     ! determine the destination (ensuring that it is a folder)
  22.     set cp_folder=%WHERE%
  23.     if "%2 " == " " goto FOLDER_OK_LBL
  24.     if not existdir "%2" goto ERR_LBL
  25.     set cp_folder=%2
  26. :FOLDER_OK_LBL
  27.  
  28.     ! do the copying
  29.     onerror ERR_LBL
  30.     if not existdir "%1" goto COPY_FILE_LBL
  31.     copydir "%1" "%cp_folder%"
  32.     goto DONE_LBL
  33. :COPY_FILE_LBL
  34.     copy "%1" "%cp_folder%"
  35.     goto DONE_LBL
  36.  
  37. :ERR_LBL
  38.     show %doserr%
  39.  
  40. :DONE_LBL
  41.     ! remove the global variables
  42.     set cp_name=
  43.     set cp_folder=
  44.